//
// Created by jiangpenghui on 2023/4/10.
//

#include <iostream>
#include "Container_01.h"
#include <iterator>

using namespace std;
// 初始化
std::array<int, 20> array_p = {10, 30, 50};

typedef array<int, 5> array_5;
typedef array<int, 6> array_6;

void printArray() {

    // 使用迭代器打印数组，复制元素打印
    copy(begin(array_p), end(array_p), ostream_iterator<int>(std::cout, " "));

    cout << " " << endl;
    array_5 array5 = {2, 4, 5, 6, 6};
    array_5 array5_copy = {2, 4, 5, 6, 8};
    array_6 array6 = {2, 4, 5, 6, 8, 5};



    // 定范围中第一个元素地址的 const 迭代器
    cout << "[";
    for (auto item = array5.cbegin(); item != array5.cend(); item++) {
        cout << " " << *item << ",";
    }
    cout << "]" << endl;
    // 同上
    for (const auto &item: array5)
        cout << "  " << item << endl;

    cout << "array[1] is :" << get<1>(array5) << endl;

    cout << "=======================" << endl;

    // 随机访问迭代器 指向序列的第一个元素
    auto begin_p = array6.begin();
    cout << *++begin_p << endl;


    cout << "=======array equal ============" << endl;

    // error 类型不一致 无法比较
    std::cout << std::boolalpha << " " << (array5 == array5_copy);


}

struct struct_3 {
    int a;
    float b;
    string c;

    struct_3() {}

};

typedef array<struct_3, 2> array_2_struct;

void printArray_struct() {
    array_2_struct array2Struct;

}


